﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Didsoft.Silverlight.ViewModel.Data;
using ICIA.ARojas.Silverlight.DataService;
using ICIA.ARojas.Silverlight.Entities;
using System.Collections.ObjectModel;
using ICIA.ARojas.Silverlight.Curso.ViewModel;

namespace ICIA.ARojas.Visual.CursoRealizado.ViewModel
{
    public class VmCursoRealizado : DataModelBase<ICIA.ARojas.Silverlight.Entities.CursoRealizado>
    {

        internal VmCurso vmCurso;
        public event EventHandler OnGuardado;


        private ObservableCollection<Curso> cursos;
        public ObservableCollection<Curso> Cursos
        {
            get { return cursos; }
            set { cursos = value; FirePropertyChanged("Cursos"); }
        }

        public VmCursoRealizado()
        {
            SetDataService(new CursoRealizadoDataService());
            SelectedItem = new Silverlight.Entities.CursoRealizado();
            vmCurso = new VmCurso();
            vmCurso.DataService.OnEntityGetAllCompleted += new EventHandler<GetAllEntitiesEventArgs<Curso>>(DataService_OnEntityGetAllCompleted);
            
        }        

        void DataService_OnEntityGetAllCompleted(object sender, GetAllEntitiesEventArgs<Curso> e)
        {
            if (e.AssertResult)
            {
                Cursos = e.ListResult;
            }
        }
    }
}
